<?
 class Controller_Catalog extends Controller_Base {
 	
 	function index($args) {
 		$template	= new Template('catalog.tmpl'); 
	
		$goods 		= new Model_Good();
		
		$sizes 		= new Model_Size();
		$colors		= new Model_Color();
		$structures = new Model_Structure();
//print "<pre>";
//print_r($goods->find(array(sex => $args[0] === 'male' ? 1 : 0, category => $args[1])));
//print "<pre>";
		if($args[0] === 'female' || $args[0] === 'male') {
			$template->setArgs(array(
				sex 		=> $args[0],
				categories	=> $goods->getCategories( $args[0] === 'male' ? 1 : 0 ),
				goods		=> $goods->find(array(sex => $args[0] === 'male' ? 1 : 0, category => $args[1])),
				sizes			=> $sizes->getList(),
				colors			=> $colors->getList(),
				structures		=> $structures->getList(),

			));
		} else {
			$template->setArg(sex_switch,1);
		}
		
// 		$template->setArgs(
// 			array( 
//				_user			=> $this->user,
//				menu			=> $this->menu->getMenu(1),
//				sex_switch		=> ($args[0] === 'female' || $args[0] === 'male') ? false : true
				
//				email			=> $this->user->email,
//				realname		=> $this->user->realname,
//				user_id			=> $this->user->id,
//				goods			=> $goods->find(array(category => $args[0])),
//				categories		=> $goods->getCategories(),
//			)
//		);
		
 		return array(
 			status 		=> 0,
 			template	=> $template
 		);
 	}

	function male($args) {
		return $this->index(array_merge(array('male'),$args));
	}

	function female($args) {
		return $this->index(array_merge(array('female'),$args));
	}
 	
 	function suits($args) {
 		$template	= new Template('suits.tmpl');

		$goods 		= new Model_Good();
		
		$suits		= new Model_Suit();

		$basket 	= new Model_Basket();
		
		$sizes 		= new Model_Size();
		$colors		= new Model_Color();
		$structures = new Model_Structure(); 		

 		$template->setArgs(
 			array( 
				_user			=> $this->user,
				menu			=> $this->menu->getMenu(1),
				email			=> $this->user->email,
				realname		=> $this->user->realname,
				user_id			=> $this->user->id,
				sizes			=> $sizes->getList(),
				colors			=> $colors->getList(),
				structures		=> $structures->getList(),
				suits			=> $suits->find(),
				details			=> $suits->details(),
//				goods			=> $goods->find(array(category => $args[0])),
				categories		=> $goods->getCategories(),
			)
		);
 		
 		return array(
 			status 		=> 0,
 			template	=> $template
 		); 		 
 	}
 }